
Shade = new function() { /*新建一个Shade函数，当隐藏图层显示时，将网页后面变暗*/
	var handle = {};
	var shade;
	handle.show = function() {
		if (!shade) {
			shade = document.createElement('div'); /*新建一个div元件*/
			shade.className = 'tb-shade'; /*设置shade区CSS为’tb-shade’，名称和第三步中的一致*/
			document.body.appendChild(shade);
		}		with((document.compatMode=='CSS1Compat')?document.documentElement:document.body) {
			var ch = clientHeight, sh = scrollHeight;
			var cw = clientWidth, sw = scrollWidth;
			shade.style.height = (sh > ch ? sh : ch) + 'px';
			shade.style.width = (sw > cw ? sw : cw)  + 'px';
			shade.style.display = 'block';
		}
	};
	handle.hide = function() {
		shade.style.display = 'none';
	};
	return handle;
 } 
/*
 function showPanel() { /*显示panel函数*/
/*	 Shade.show();/* 执行Shade.show()命令，即后面为暗色*/
/*	 document.getElementById('loginPanel').style.display = 'block'; /*这里的Panel应和隐藏图层内名称一致 */
/*	 document.getElementById('loginFrame').src = "login.html"; /*设置frame的源，可自行修改，同时“frame”名称和隐藏图层内一致*/
//	 document.getElementById('loginPanel').scrollIntoView();
// } 
/* function hidePanel() { /*隐藏panel函数 */
/*	 Shade.hide();/*执行Shade.hide命令，暗色消失*/
/*	 document.getElementById('loginPanel').style.display = 'none'; /*将隐藏图层CSS设置为none，即不显示*/
/* }
*/

var popup_dragging = false;
var popup_target;
var popup_mouseX;
var popup_mouseY;
var popup_mouseposX;
var popup_mouseposY;
var popup_oldfunction;
function popup_display(x)
{
  var win = window.open();
  for (var i in x) win.document.write(i+' = '+x[i]+'<br>');
}
// ----- popup_mousedown -------------------------------------------------------
function popup_mousedown(e)
{
  var ie = navigator.appName == "Microsoft Internet Explorer";
  if ( ie && window.event.button != 1) return;
  if (!ie && e.button            != 0) return;
  popup_dragging = true;
  popup_target   = this['target'];
  popup_mouseX   = ie ? window.event.clientX : e.clientX;
  popup_mouseY   = ie ? window.event.clientY : e.clientY;
  if (ie)
       popup_oldfunction      = document.onselectstart;
  else popup_oldfunction      = document.onmousedown;
  if (ie)
       document.onselectstart = new Function("return false;");
  else document.onmousedown   = new Function("return false;");
}
// ----- popup_mousemove -------------------------------------------------------
function popup_mousemove(e)
{
  if (!popup_dragging) return;
  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(popup_target);
  var mouseX = ie ? window.event.clientX : e.clientX;
  var mouseY = ie ? window.event.clientY : e.clientY;
  element.style.left = (element.offsetLeft+mouseX-popup_mouseX)+'px';
  element.style.top  = (element.offsetTop +mouseY-popup_mouseY)+'px';
  popup_mouseX = ie ? window.event.clientX : e.clientX;
  popup_mouseY = ie ? window.event.clientY : e.clientY;
}
// ----- popup_mouseup ---------------------------------------------------------
function popup_mouseup(e)
{
  if (!popup_dragging) return;
  popup_dragging = false;
  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(popup_target);
  if (ie)
       document.onselectstart = popup_oldfunction;
  else document.onmousedown   = popup_oldfunction;
}
// ----- popup_exit ------------------------------------------------------------
function popup_exit(e)
{
  Shade.hide();
  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(popup_target);
  popup_mouseup(e);
  element.style.visibility = 'hidden';
  element.style.display    = 'none';
}
// ----- popup_show ------------------------------------------------------------
function popup_show()
{
  Shade.show();
  element      = document.getElementById('popup');
  drag_element = document.getElementById('popup_drag');
  exit_element = document.getElementById('popup_exit');
  element.style.position   = "absolute";
  element.style.visibility = "visible";
  element.style.display    = "block";
    element.style.left = (document.documentElement.scrollLeft+popup_mouseposX-200)+'px';
    element.style.top  = (document.documentElement.scrollTop +popup_mouseposY+100)+'px';
  drag_element['target']   = 'popup';
  drag_element.onmousedown = popup_mousedown;
  exit_element.onclick     = popup_exit;
}
// ----- popup_mousepos --------------------------------------------------------
function popup_mousepos(e)
{
  var ie = navigator.appName == "Microsoft Internet Explorer";
  popup_mouseposX = ie ? window.event.clientX : e.clientX;
  popup_mouseposY = ie ? window.event.clientY : e.clientY;
}
// ----- Attach Events ---------------------------------------------------------
if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent('onmousedown', popup_mousepos);
else document.addEventListener('mousedown', popup_mousepos, false);
if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent('onmousemove', popup_mousemove);
else document.addEventListener('mousemove', popup_mousemove, false);
if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent('onmouseup', popup_mouseup);
else document.addEventListener('mouseup', popup_mouseup, false);
